﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace NLUNZ.UserControls
{
    public partial class NewsProperty : System.Web.UI.UserControl
    {
        public string currentUrl;
        protected void Page_Load(object sender, EventArgs e)
        {
            currentUrl = HttpContext.Current.Request.Url.AbsolutePath;

        }

        /// <summary>
        /// a fix to resolve the problem when the page first loaded without any row is selected. 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LinqDataSourceDetailsEdit_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            foreach (KeyValuePair<string, object> kvp in e.WhereParameters)
            {
                if (kvp.Value == null)
                {
                    e.Cancel = true;
                    return;
                }
            }

        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            HtmlMeta metatag = new HtmlMeta();
            metatag.Attributes.Add("http-equiv", "X-UA-Compatible");
            metatag.Attributes.Add("content", "IE=8;IE=7;IE=5");
            Page.Header.Controls.AddAt(0, metatag);
        }

        protected void LinkButton1_Click(object sender, ImageClickEventArgs e)
        {
           Response.Redirect(currentUrl);
        }
    }
}